<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  // 2s 之后返回双倍的值
  function doubleAfter2seconds(num) {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve(2 * num)
      }, 2000);
    } )
  }

  (async function testResult() {
    //放一个返回promise 对象的表达式。注意await 关键字只能放到async 函数里面
    // let result = await doubleAfter2seconds(30);
    // console.log(result);
    let first = await doubleAfter2seconds(30);
    let second = await doubleAfter2seconds(50);
    let third = await doubleAfter2seconds(30);
    console.log(first);
    console.log(second);
    console.log(third);
  })();
</script>
</body>
</html>